package net.edu_soft.ec.asset.service.impl;

import net.edu_soft.ec.asset.mapper.MessageTypeMapper;
import net.edu_soft.ec.asset.pojo.MessageType;
import net.edu_soft.ec.asset.pojo.MessageTypeExample;
import net.edu_soft.ec.asset.service.MessageTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MessageTypeServiceImpl implements MessageTypeService {
    @Autowired
    private MessageTypeMapper messageTypeMapper;

    @Override
    public int insert(MessageType record) {

        //验证父id是否存在
        if (record.getMark()!=null && record.getName()!=null){
            record.setCreateDate(new Date());
            record.setStatus(1);
            System.out.println("存入数据库的数据："+record);
            return messageTypeMapper.insert(record);
        }
        return 0;
    }

    @Override
    public List<MessageType> selectByExample() {
        MessageTypeExample messageTypeExample=new MessageTypeExample();
        return messageTypeMapper.selectByExample(messageTypeExample);
    }

    @Override
    public int deleteByPrimaryKey(Integer messageTypeId) {
        return messageTypeMapper.deleteByPrimaryKey(messageTypeId);
    }
}
